package com.sundayfactory.workpaychart;

import java.lang.reflect.Type;
import java.util.Collection;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import com.google.myjson.reflect.TypeToken;


public class paserpaylist extends Masterpaser {
    public String Year;
    public domain_payinfo info;
    public paserpaylist(String Year) {
	this.Year = Year;
	Url = "http://parkjooil.co.kr/workpay/api_selectList?year="+Year;
    }
    
    @Override
    public void startPaser() {
	
	
	//info = gson.fromJson(JsonResult, domain_payinfo.class);
	
	try {
	    	info = new domain_payinfo();
	    	JSONObject jsonObject = new JSONObject(JsonResult);
	    	Type collectionType = new TypeToken<Collection<domain_Paylist>>(){}.getType();
		Collection<domain_Paylist>  infoget = gson.fromJson(jsonObject.getString("result"), collectionType);
		info.setResult((List<domain_Paylist>) infoget);
		
		 collectionType = new TypeToken<Collection<domain_detail>>(){}.getType();
		Collection<domain_detail>  detail = gson.fromJson(jsonObject.getString("detail"), collectionType);
		if(detail.size() > 0){
		    info.setDetail(((List<domain_detail> )detail).get(0));
			    
		}
		
	} catch (JSONException e) {
	    // TODO Auto-generated catch block
	    e.printStackTrace();
	}
	
    }
    
}
